Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • add "positive sign" before estimate value | collect style

    Hi ,

    I was wondering if is it possible to add a "positive sign" before estimate value, same way, it occurs automatically with negative values.

    Code:
    webuse auto
    (1978 automobile data)
    
    . reg price mpg headroom weight length turn displacement
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(6, 67)        =      8.52
           Model |   274827242         6  45804540.3   Prob > F        =    0.0000
        Residual |   360238154        67  5376688.87   R-squared       =    0.4328
    -------------+----------------------------------   Adj R-squared   =    0.3820
           Total |   635065396        73  8699525.97   Root MSE        =    2318.8
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -98.60354   80.80491    -1.22   0.227    -259.8908    62.68374
        headroom |  -565.2827   378.3782    -1.49   0.140    -1320.529    189.9633
          weight |   4.584672    1.39686     3.28   0.002     1.796528    7.372815
          length |  -58.35298   41.27537    -1.41   0.162     -140.739    24.03301
            turn |  -338.0579   127.1015    -2.66   0.010    -591.7535   -84.36232
    displacement |   3.657153   6.726976     0.54   0.588    -9.769948    17.08425
           _cons |   19762.45   6048.361     3.27   0.002     7689.874    31835.03
    ------------------------------------------------------------------------------
    
    . qui etable, cstat(_r_b,nformat(%3.2f))
    
    . collect style cell result[_r_b] , nformat("%3.1f") 
    
    . collect layout (coleq#colname#result[_r_b] result[N]) (etable_depvar#stars) ()
    
    Collection: ETable
          Rows: coleq#colname#result[_r_b] result[N]
       Columns: etable_depvar#stars
       Table 1: 8 x 2
    
    ---------------------------------
                              price  
    ---------------------------------
    Mileage (mpg)            -98.6   
    Headroom (in.)          -565.3   
    Weight (lbs.)              4.6 **
    Length (in.)             -58.4   
    Turn circle (ft.)       -338.1 **
    Displacement (cu. in.)     3.7   
    Intercept              19762.5 **
    Number of observations      74   
    ---------------------------------
    would be:


    Code:
    ---------------------------------
                              price  
    ---------------------------------
    Mileage (mpg)            -98.6   
    Headroom (in.)          -565.3   
    Weight (lbs.)              +4.6 **
    Length (in.)             -58.4   
    Turn circle (ft.)       -338.1 **
    Displacement (cu. in.)     3.7   
    Intercept              19762.5 **
    Number of observations      74   
    ---------------------------------

    thks

  • #2
    There is no numeric format that displays positive numbers with a plus sign in front of them. Note that this is not a collect issue; there are no options for this in estout (from SSC) or other exporting commands that I know of. People generally accept this convention, as there is no ambiguity in understanding that an unsigned coefficient is positive. You could request a string format, but then how would you handle negative coefficients? If all coefficients are positive, appending a plus sign could work, but the output might look strange.

    Code:
    sysuse auto, clear
    reg price mpg headroom weight length turn displacement
    etable, keep(weight displacement _cons)
    collect layout (coleq#colname[weight displacement _cons]#result[_r_b _r_se] result[N]) (etable_depvar#stars[value])
    collect style cell result[_r_b] , sformat("+%s")
    collect preview
    Res.:

    Code:
    . collect style cell result[_r_b] , sformat("+%s")
    
    . 
    . collect preview
    
    ---------------------------------
                              price  
    ---------------------------------
    Weight (lbs.)              +4.585
                              (1.397)
    Displacement (cu. in.)     +3.657
                              (6.727)
    Intercept              +19762.453
                           (6048.361)
    Number of observations         74
    ---------------------------------

    Comment


    • #3
      thks Andrew,

      The project I am working aims a non-technical audience, and , in this particular context, signs , also, means a "favorable" and "negative" consequence for the business. Prefixing signs to the estimate would help to emphasize that.

      My plan B is to move to coefplot (from SSC).

      thks, again.

      Comment

      Working...
      X